package com.labichaoka.chaoka.ui.bank.display;

import com.labichaoka.chaoka.entity.BankCardListResponse;
import com.labichaoka.chaoka.entity.IsOpenAcountRequest;
import com.labichaoka.chaoka.entity.IsOpenAcountResponse;

/**
 * Created by ruan on 2018/8/8.
 */

public class BankCardDisplayPresenterImpl implements BankCardDisplayPresenter,BankCardDisplayInteractor.OnFinishedListener {
    private BankCardDisplayInteractor interactor;
    private BankCardDisplayView view;

    public BankCardDisplayPresenterImpl(BankCardDisplayInteractor interactor, BankCardDisplayView view) {
        this.interactor = interactor;
        this.view = view;
    }

    @Override
    public void getBankList() {
        if (view !=null){
            view.showProgress();
        }
        interactor.getBankList(this);
    }

    @Override
    public void isOpenAcount(IsOpenAcountRequest request) {
        if (view!=null){
            view.showProgress();
        }
        interactor.isOpenAcount(request,this);
    }

    @Override
    public void onDestroy() {
        view=null;
    }

    @Override
    public void onQueryListSuccessed(BankCardListResponse response) {
        view.hideProgress();
        view.queryBankList(response);
    }

    @Override
    public void onQueryListFailed() {
        view.hideProgress();
    }

    @Override
    public void onIsOpenAcountSucc(IsOpenAcountResponse response) {
        view.hideProgress();
        view.isOpenAcountCallback(response);
    }

    @Override
    public void onIsOpenAcountFailed() {
        view.hideProgress();
    }
}
